/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_USUA_SIST_MEDI")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbUsuaSistMedi.findAll", query = "SELECT a FROM AmTbUsuaSistMedi a"),
    @NamedQuery(name = "AmTbUsuaSistMedi.findByCdUsua", query = "SELECT a FROM AmTbUsuaSistMedi a WHERE a.amTbUsuaSistMediPK.cdUsua = :cdUsua"),
    @NamedQuery(name = "AmTbUsuaSistMedi.findByCdMedi", query = "SELECT a FROM AmTbUsuaSistMedi a WHERE a.amTbUsuaSistMediPK.cdMedi = :cdMedi")})
public class AmTbUsuaSistMedi implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AmTbUsuaSistMediPK amTbUsuaSistMediPK;
    @JoinColumn(name = "CD_USUA", referencedColumnName = "CD_USUA", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private AmTbUsuaSist amTbUsuaSist;
    @JoinColumn(name = "CD_TIPO_ACES_MEDI", referencedColumnName = "CD_TIPO_ACES_MEDI")
    @ManyToOne(optional = false)
    private AmTbTipoAcesMedi cdTipoAcesMedi;
    @JoinColumn(name = "CD_MEDI", referencedColumnName = "CD_MEDI", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private AmTbMedi amTbMedi;
    @JoinColumn(name = "CD_LOCA_ATEN_MEDI", referencedColumnName = "CD_LOCA_ATEN_MEDI")
    @ManyToOne(optional = false)
    private AmTbLocaAtenMedi cdLocaAtenMedi;

    public AmTbUsuaSistMedi() {
    }

    public AmTbUsuaSistMedi(AmTbUsuaSistMediPK amTbUsuaSistMediPK) {
        this.amTbUsuaSistMediPK = amTbUsuaSistMediPK;
    }

    public AmTbUsuaSistMedi(int cdUsua, int cdMedi) {
        this.amTbUsuaSistMediPK = new AmTbUsuaSistMediPK(cdUsua, cdMedi);
    }

    public AmTbUsuaSistMediPK getAmTbUsuaSistMediPK() {
        return amTbUsuaSistMediPK;
    }

    public void setAmTbUsuaSistMediPK(AmTbUsuaSistMediPK amTbUsuaSistMediPK) {
        this.amTbUsuaSistMediPK = amTbUsuaSistMediPK;
    }

    public AmTbUsuaSist getAmTbUsuaSist() {
        return amTbUsuaSist;
    }

    public void setAmTbUsuaSist(AmTbUsuaSist amTbUsuaSist) {
        this.amTbUsuaSist = amTbUsuaSist;
    }

    public AmTbTipoAcesMedi getCdTipoAcesMedi() {
        return cdTipoAcesMedi;
    }

    public void setCdTipoAcesMedi(AmTbTipoAcesMedi cdTipoAcesMedi) {
        this.cdTipoAcesMedi = cdTipoAcesMedi;
    }

    public AmTbMedi getAmTbMedi() {
        return amTbMedi;
    }

    public void setAmTbMedi(AmTbMedi amTbMedi) {
        this.amTbMedi = amTbMedi;
    }

    public AmTbLocaAtenMedi getCdLocaAtenMedi() {
        return cdLocaAtenMedi;
    }

    public void setCdLocaAtenMedi(AmTbLocaAtenMedi cdLocaAtenMedi) {
        this.cdLocaAtenMedi = cdLocaAtenMedi;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (amTbUsuaSistMediPK != null ? amTbUsuaSistMediPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbUsuaSistMedi)) {
            return false;
        }
        AmTbUsuaSistMedi other = (AmTbUsuaSistMedi) object;
        if ((this.amTbUsuaSistMediPK == null && other.amTbUsuaSistMediPK != null) || (this.amTbUsuaSistMediPK != null && !this.amTbUsuaSistMediPK.equals(other.amTbUsuaSistMediPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbUsuaSistMedi[ amTbUsuaSistMediPK=" + amTbUsuaSistMediPK + " ]";
    }
    
}
